package com.h.ops.controller;

import com.h.ops.constant.Constants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/")
@RestController
public class ProducerController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/quorum")
    // 集群
    public String quorum() {
        String msg = "quorum test...";
        rabbitTemplate.convertAndSend("", Constants.QUORUM_QUEUE,msg);
        return "集群的消息发送成功";
    }

    // 集群 + 负载均衡
    @RequestMapping("/haproxy")
    public String haproxy() {
        String msg = "haproxy test...";
        rabbitTemplate.convertAndSend("", Constants.CLUSTER_QUEUE, msg);
        return "负载均衡的消息发送成功";
    }
}
